package com.ruoyi.faceApi.click;

import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.faceApi.entity.FaceIdentification;
import com.ylsoft.android.facerepeater.net.thrift.server.transaction.AccessThriftService;
import com.ylsoft.android.facerepeater.net.thrift.server.transaction.TDeviceStateInfo;
import com.ylsoft.android.facerepeater.net.thrift.server.transaction.TVerifyRecordInfo;
import com.ylsoft.android.iacterminal.net.thrift.server.transaction.AIFTThriftService;
import org.apache.thrift.TException;

/**
 * @Author: wwy
 * @Date: 2021/6/23 11:18
 */
public class FaceCallBack implements AccessThriftService.Iface {
    public static IFaceCallBack faceCallBack;

    @Override
    public int UploadVerifyRecord(int uploadType, TVerifyRecordInfo tInfo) throws TException {
        System.out.println("回调执行"+tInfo.toString());

        if(faceCallBack == null){
            return 0;
        }
        FaceIdentification faceIdentification = new FaceIdentification();
        faceIdentification.setDeviceID(tInfo.getDeviceID());
        faceIdentification.setHalfBodyImage(tInfo.getHalfBodyImage());
        faceIdentification.setName(tInfo.getName());
        faceIdentification.setPersonId(tInfo.personId);
        //是否是临时人员
        int personType = tInfo.getPersonType();
        if(StringUtils.isEmpty(tInfo.getName())){
            if(personType == 0){
                //未知人员
                faceIdentification.setPersonType(2);
            }else if (personType == 2){
                faceIdentification.setPersonType(3);
            }

        }else{
            //常驻人员
            faceIdentification.setPersonType(0);
        }


        faceCallBack.invoke(faceIdentification);
        return 0;
    }

    @Override
    public int UploadDeviceState(String deviceID, TDeviceStateInfo tInfo) throws TException {
        System.out.println("回调执行2"+tInfo.toString());
        return 0;
    }
}
